local skynet = require 'skynet'
require 'skynet.manager'

local class = require 'nggs.base.class'

skynet.error('lesson2 started')

local Base = class('Base')

function Base:Constructor(a, b)
    self._a = a
    self._b = b
    skynet.error('Base:Constructor _a=' .. self._a)
    skynet.error('Base:Constructor _b=' .. self._b)
end

function Base:foo()
    skynet.error('Base:foo')
end

function Base:bar()
    skynet.error('Base:bar')
end

local Derive = class('Derive', Base)

function Derive:Constructor(a, b, c)
    Base.Constructor(self, a, b)
    self._c = c
    skynet.error('Derive:Constructor _a=' .. self._a)
    skynet.error('Derive:Constructor _b=' .. self._b)
    skynet.error('Derive:Constructor _c=' .. self._c)
end

function Derive:foo()
    Base.foo(self)
    skynet.error('Derive:foo')
end

skynet.start(
    function()
        -- skynet.timeout(
        --     300,
        --     function()
        --         skynet.error("lesson2 end")
        --         skynet.sleep(0)
        --         skynet.abort()
        --     end
        -- )

        local b = Base.New('1', 2)
        b.foo()
        b.bar()

        local d = Derive.New('3', 4, '5')
        d.foo()
        d.bar()
    end
)
